package com.xyzh05.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Entity
@Table(name="major")
@Searchable
@XmlRootElement
public class Major extends BaseObject implements Serializable {
	private static final long serialVersionUID = 4992539354546847050L;
	
	private Long id;
    private Long level;
    private String name;
    private String description;
    private Long category;

    @Id @GeneratedValue(strategy=GenerationType.AUTO) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="level", nullable=false)
    @SearchableProperty
    public Long getLevel() {
        return this.level;
    }
    
    public void setLevel(Long level) {
        this.level = level;
    }
    
    @Column(name="name", nullable=false)
    @SearchableProperty
    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(name="description", length=65535)
    @SearchableProperty
    public String getDescription() {
        return this.description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    @Column(name="category")
    @SearchableProperty
    public Long getCategory() {
        return this.category;
    }
    
    public void setCategory(Long category) {
        this.category = category;
    }

    
    public Major(){    	
    }
    
    public Major(Long id, String name){
    	this.id = id;
    	this.name = name;
    }
    
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Major pojo = (Major) o;

        if (level != null ? !level.equals(pojo.level) : pojo.level != null) return false;
        if (name != null ? !name.equals(pojo.name) : pojo.name != null) return false;
        if (description != null ? !description.equals(pojo.description) : pojo.description != null) return false;
        if (category != null ? !category.equals(pojo.category) : pojo.category != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (level != null ? level.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (category != null ? category.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("level").append("='").append(getLevel()).append("', ");
        sb.append("name").append("='").append(getName()).append("', ");
        sb.append("description").append("='").append(getDescription()).append("', ");
        sb.append("category").append("='").append(getCategory()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
